﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace FPC.Offer.UI.GeneralProcessor.SkyDriveHand
{
    /// <summary>
    /// DelZSubHandler 的摘要说明
    /// </summary>
    public class DelZSubHandler : IHttpHandler
    {
        FPC.Offer.Service.System_SubfolderTableService Sky = new Service.System_SubfolderTableService();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var id = Convert.ToInt32(context.Request["id"]);
            if (id > 0)
            {

                Model.Subfolder c = Sky.Find(w => w.SId == id).FirstOrDefault();

                int a = Sky.Delete(c);
                if (a > 0)
                {

                    string upath = c.SUrl;
                    if (Directory.Exists(upath))
                    {
                        context.Response.Write(0);
                        return;
                    }
                    else
                    {
                        File.Delete(upath);
                        context.Response.Write(1);
                        return;
                    }


                }
                else
                {
                    context.Response.Write(0);

                }

            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}